<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>用户编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/news.css"/>
    <style>
        li {
            list-style: inherit !important;
        }
    </style>
</head>

<body class="childrenBody">
<form class="layui-form" action="">
    <div style="display: inline-block; width: 90%; height: 450px; padding: 10px; border: 1px solid #ddd; overflow: auto;">
        <ul id="tree" class="layui-box layui-tree">
        </ul>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <a class="layui-btn layui-btn-normal" lay-filter="demo1" id="edit">立即修改</a>
            <a class="layui-btn layui-btn-primary close">取消</a>
        </div>
    </div>
</form>
<script type="text/javascript" src="../../js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script src="/layui/layui.all.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="../../js/wangEditor.js"></script>
<script type="text/javascript" src="../../js/basic.js"></script>
<script>

    var orgId = 0;

    function showTree() {
        var btvId = GetQueryString("btvId");
        $("#tree").empty();
        $.ajax({
            url: '/btvorg/list',
            type: 'POST',
            data: {
                btvId: btvId,
                parentId: 0,
                getTree: 1
            },
            dataType: 'json',
            success: function (data) {
                if (data.status == '0') {
                    console.log(data.result)
                    layui.tree({
                        elem: '#tree'
                        , nodes: data.result
                        , click: function (node) {
                            orgId = node.id;
                        }
                    });
                }
            }
        });
    }

    $("body").on("mousedown", ".layui-tree a", function () {

        $(".layui-tree a cite").css('color', '#333');
        $(this).find('cite').css('color', 'red');

    });
    layui.use(['form'], function () {
    });


    //点击取消关闭当前弹窗
    $(".close").click(function () {
//当你在iframe页面关闭自身时
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    })

    $("#edit").click(function () {
        var id = GetQueryString("id");


        $.ajax({
            type: "post",
            url: "/user/update",
            data: {
                btvOrgId: orgId,
                id: id
            },
            dataType: "json",
            success: function (data) {
                if (data.status == 0) {
                    var index = top.layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
                    setTimeout(function () {
                        layer.closeAll("iframe");
                        top.layer.msg("修改成功！");
                        //刷新父页面
                        parent.getList({});
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    }, 500);
                } else {
                    layer.msg(data.msg, {icon: 1});
                }
            }
        });
    });


    $(document).ready(function () {
        showTree();

    });

</script>
</body>

</html>